package com.job.model;

import org.hibernate.annotations.GenericGenerator;

import javax.persistence.*;

/**
 * 工作分类
 * @author hasee
 */
@Entity
@Table()
public class Profession {
    /**
     * 工作id
     */
    private int professionId;
    /**
     * 工作名字
     */
    private String professionName;
    /**
     * 父类id
     */
    private int parentId;
    /**
     * 类别id
     */
    private int sortId;

    @Basic
    @Column(name = "professionName")
    public String getProfessionName() {
        return professionName;
    }

    public void setProfessionName(String professionName) {
        this.professionName = professionName;
    }

    @Basic
    @Column(name = "parentId")
    public Integer getParentId() {
        return parentId;
    }

    public void setParentId(Integer parentId) {
        if (parentId==null){
            this.parentId = 0;
        }else {
            this.parentId = parentId;
        }

    }

    @Basic
    @Column(name = "sortId")
    public Integer getSortId() {
        return sortId;
    }

    public void setSortId(Integer sortId) {
        this.sortId = sortId;
    }

    @Id
    @GeneratedValue(generator="increment")
    @Column(name = "professionId")
    @GenericGenerator(name="increment", strategy = "increment")
    public int getProfessionId() {
        return professionId;
    }

    public void setProfessionId(int professionId) {
        this.professionId = professionId;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Profession that = (Profession) o;

        if (professionId != that.professionId) return false;
        if (parentId != that.parentId) return false;
        if (sortId != that.sortId) return false;
        if (professionName != null ? !professionName.equals(that.professionName) : that.professionName != null)
            return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = professionId;
        result = 31 * result + (professionName != null ? professionName.hashCode() : 0);
        result = 31 * result + parentId;
        result = 31 * result + sortId;
        return result;
    }

    @Override
    public String toString() {
        return "Profession{" +
                "professionId=" + professionId +
                ", professionName='" + professionName + '\'' +
                ", parentId=" + parentId +
                ", sortId=" + sortId +
                '}';
    }
}
